<template>
	<div class="school">
		<h2>我是School组件</h2>
		<h3>学校名称：{{name}}</h3>
		<h3>学校地址：{{address}}</h3>
		<button @click="sendNameToApp">把学校名称传给App</button> <br/><br/>
		<button @click="sendAddressToApp">把学校地址传给App</button> <br/><br/>
		<button @click="unbindHaha">解绑我身上的haha事件（haha事件用于给App传学校名称）</button> <br/><br/>
		<button @click="death">点我销毁School组件的vc</button>
	</div>
</template>

<script>
	export default {
		name:'School',
		data() {
			return {
				name:'尚硅谷',
				address:'宏福科技园'
			}
		},
		methods: {
			sendNameToApp(){
				//触发haha这个自定义事件
				this.$emit('haha',this.name)
			},
			sendAddressToApp(){
				this.$emit('xixi',this.address)
			},
			unbindHaha(){
				this.$off('haha')
			},
			death(){
				this.$destroy()
			},
		}
	}
</script>

<style scoped>
	.school {
		background-color: skyblue;
		padding: 20px;
	}
</style>